<?php
class pageAction extends Action {
	function index(){
		$page = addslashes($_GET['page']);
		
		pubAction::get_slist();
		
		$arr = array('pay','guide','free','apply','address','about','contact_us','signup','links','online');
		$arr_name = array('pay'=>'支付方式','guide'=>'培训向导','free'=>'免费优惠','apply'=>'在线报名','address'=>'教学地点','about'=>'关于我们','contact_us'=>'联系方式','signup'=>'在线报名','online'=>'在线学员','links'=>'友情链接','error'=>'访问出错');
		if($page == 'signup'){
			include('Conf/arr.php');
			$this->assign('like',explode(',',$like));
		    $this->assign('state',explode(',',$state));
		}

		if($page == 'signup'){
			$user = D('kecheng');
			$klist = $user->field('id,title,url')->findAll();
			$this->assign('klist',$klist);
		}
		
		if($page == 'online'){
			$user = D('online');
			$list = $user->findAll();
			$this->assign('list',$list);
		}
		
		$tpl = in_array($page,$arr) ? $page : 'error';
		
		$this->assign('page_name',$arr_name[$tpl]);
		$this->display('default@page_'.$tpl);
	}
	
	function form_post(){
	    $name = str_set($_POST['name']);
	    $nickname = str_set($_POST['nickname']);
	    $qq = $_POST['qq'];
	    
	    if(empty($name) || !is_numeric($qq) || empty($nickname)){
	    	die('<script>alert("信息有误!")</script>');
	    }else {
	    	$user = D('online');
	    	$n = $user->where("qq='$qq'")->count();

	    	if($n==0){
	    		$arr['name']=$name;
	    		$arr['nickname']=$nickname;
	    		$arr['qq']=$qq;
	    		$result = $user->add($arr);
	    		if($result){
	    			echo '<script>alert("加入成功!");window.top.location.replace("/peixun-online.html")</script>';
	    		}else {
	    			echo '<script>alert("加入失败!请重试!");window.top.location.replace("/peixun-online.html")</script>';
	    		}
	    	}else {
	    		echo '<script>alert("此Q号已经加入!")</script>';
	    	}
	    }
	}
}
?>